
#from moviepy.editor import *

#my_audio = AudioFileClip("example.mp4")
#my_audio.write_audiofile("example.wav")


from paddlespeech.cli.asr.infer import ASRExecutor
asr = ASRExecutor()
result = asr(audio_file="example.wav",force_yes=True)
print(result)
from paddlespeech.cli.text.infer import TextExecutor
text_punc = TextExecutor()
result = text_punc(text=result)
print(result)

exit()

import numpy as np
import librosa
import matplotlib.pyplot as plt

audio, freq = librosa.load("example.wav")
time = np.arange(0, len(audio)) / freq

plt.figure(figsize=(14, 12))


plt.subplot(3,1,1)
librosa.display.waveshow(audio, sr=freq)
plt.title('waveform')
plt.xlabel('time')
plt.ylabel('amplitude')


#plt.savefig("example.png")
D = librosa.stft(audio)
s_db = librosa.amplitude_to_db(np.abs(D), ref=np.max)

plt.subplot(3,1,2)
librosa.display.specshow(s_db, x_axis='time', y_axis='log')
plt.colorbar(format='%+2.0f dB')
plt.title('Log-frequency power spectrogram')
plt.xlabel('time')
plt.ylabel('frequency')

plt.subplot(3,1,3)
mfccs = librosa.feature.mfcc(y=audio, n_mfcc=13, sr=freq)
librosa.display.specshow(mfccs)
plt.xlabel('time')
plt.ylabel('mfcc')
plt.colorbar(format='%+2.0f')


plt.tight_layout()
plt.savefig("example.png")